package com.fbd.controller;

import com.fbd.internalcommon.dto.ResponseResult;
import com.fbd.internalcommon.response.NumberCodeResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NumberCodeController {

    @GetMapping("/numberCode/{size}")
    public ResponseResult numberCode(@PathVariable int size){

        // 生成n位的验证码
        double mathRandom = (Math.random() * 9) * (Math.pow(10 , size - 1));
        System.out.println("验证码为：" + (int) mathRandom);
        NumberCodeResponse response = new NumberCodeResponse();
        response.setNumberCode((int) mathRandom);
        return ResponseResult.success(response);
    }
}
